package org.nanhill.xmlro.sro.model;

import java.util.Collection;
import java.util.Iterator;

import org.nanhill.xmlro.Serializer;
import org.nanhill.xmlro.XmlroException;
import org.nanhill.xmlro.XmlroOutput;

/**
 * Serializing a collection object to xmlro output.
 * 
 * @author alin
 */
public class CollectionSerializer implements Serializer {
	public void writeObject(Object obj, XmlroOutput out) throws XmlroException {
		Collection list = (Collection) obj;
		out.writeListBegin();
		out.writeListSize(list.size());
		for (Iterator iter = list.iterator(); iter.hasNext();) {
			out.writeObject(iter.next());
		}
		out.writeListEnd();
	}
}
